﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using frag_boardgame;
using WCFCommon;

namespace WCFGameService
{
    // NOTE: If you change the interface name "IRoom" here, you must also update the reference to "IRoom" in App.config.
    [ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(IRoomCallback))]
    public interface IRoom
    {
        [OperationContract(IsInitiating = true, IsTerminating = false, IsOneWay = false)]
        JoinRoomResult JoinRoom(string roomName, string userName);

        [OperationContract(IsInitiating = false, IsTerminating = true)]
        void LeaveRoom();

        [OperationContract(IsInitiating = false, IsTerminating = false, IsOneWay = true)]
        void Say(string message);

        [OperationContract(IsInitiating = false, IsTerminating = false, IsOneWay = false)]
        Dictionary<string,int> GetUsers();

        [OperationContract(IsInitiating = false, IsTerminating = false, IsOneWay = false)]
        void SetPlayerConfiguration(PlayerConfiguration config);


        #region GameContract members

        [OperationContract(IsInitiating = false, IsTerminating = false)]
        GameData GetGameData();

        [OperationContract(IsInitiating = false, IsTerminating = false)]
        void FinishCurrentTurn();

        [OperationContract(IsInitiating = false, IsTerminating = false)]
        void MovePlayer(int delta, Direction direction);

        [OperationContract(IsInitiating = false, IsTerminating = false)]
        void Redo();

        [OperationContract(IsInitiating = false, IsTerminating = false)]
        void Shoot(int targetID);

        [OperationContract(IsInitiating = false, IsTerminating = false)]
        void Undo();

        [OperationContract(IsInitiating = false, IsTerminating = false)]
        void StartGame();
        #endregion
    }

    public interface IRoomCallback
    {
        [OperationContract(IsOneWay = true)]
        void ReceiveMessage(string sender, string message);

        //Belongs to IGameCallback
        [OperationContract(IsOneWay = true)]
        void UpdateData(GameData data, string message);

        [OperationContract(IsOneWay = true)]
        void SetCurrentPlayer();


        [OperationContract(IsOneWay = true)]
        void GameOver(string message);

    }

}
